package service

import (
	"context"
	"prombridge/internal/biz"

	pb "prombridge/api/prombridge/v1"
)

type InfoService struct {
	pb.UnimplementedInfoServer
	info biz.Info
}

func NewInfoService(i biz.Info) *InfoService {
	return &InfoService{info: i}
}

func (s *InfoService) GetInfo(ctx context.Context, req *pb.GetInfoRequest) (*pb.GetInfoReply, error) {
	if info, err := s.info.GetInfo(ctx, req.Instace); err != nil {
		return &pb.GetInfoReply{}, err
	} else {
		return &pb.GetInfoReply{PATH: info.Path, OWNER: info.Owner, ServiceID: info.ServiceID}, nil
	}
}
